<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Userprofile extends CI_Controller {

	function __construct()
    {
    	// Call the Controller constructor
    	parent::__construct();
    }

	function index()
	{
		$user_profile = $this->getProfile();
		$this->load->view('v_userprofile', $user_profile);
	}
	
	function getId()
	{
		$this->load->model('m_user', 'currentUser');
		$this->currentUser->set_user_email($this->session->userdata('useremail'));
		return $this->currentUser->get_user_id();
	}

	function getProfile()
	{
		$this->load->model('m_userprofile', 'currentUserProfile');
		$user_profile = $this->currentUserProfile->get_profile($this->getId());
		return $user_profile;
	}

	function edit_user()
	{
		$this->load->model('m_userprofile', 'newUserProfile');
		$this->newUserProfile->set_user_id($this->getId());
		$this->newUserProfile->set_first_name($_POST['fname']);
		$this->newUserProfile->set_last_name($_POST['lname']);
		$this->newUserProfile->set_address($_POST['address']);
		$this->newUserProfile->set_city($_POST['city']);
		$this->newUserProfile->set_state($_POST['state']);
		$this->newUserProfile->set_zip_code($_POST['zipcode']);
		$this->newUserProfile->set_home_phone($_POST['homephone']);

		$this->newUserProfile->edit_user_profile();
		$data["note"] = "Your user profile was successfully updated";
		$this->load->view('v_bills', $data);
	}
}

/* End of file userprofile.php */
/* Location: ./application/controllers/userprofile.php */
